home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / gscrypt1.h < prev    next >
Text File  |  1993-05-13  |  2KB  |  40 lines

  1. /* Copyright (C) 1990, 1992 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gscrypt1.h */
  20. /* Interface to Adobe Type 1 encryption/decryption. */
  21.  
  22. /* Normal public interface */
  23. typedef ushort crypt_state;
  24. int gs_type1_encrypt(P4(byte *dest, const byte *src, uint len, crypt_state *pstate));
  25. int gs_type1_decrypt(P4(byte *dest, const byte *src, uint len, crypt_state *pstate));
  26.  
  27. /* Define the encryption parameters and procedures */
  28. #define crypt_c1 ((ushort)52845)
  29. #define crypt_c2 ((ushort)22719)
  30. #define encrypt_next(ch, state, chvar)\
  31.   chvar = ((ch) ^ (state >> 8)),\
  32.   state = (chvar + state) * crypt_c1 + crypt_c2
  33. #define decrypt_this(ch, state)\
  34.   ((ch) ^ (state >> 8))
  35. #define decrypt_next(ch, state, chvar)\
  36.   chvar = decrypt_this(ch, state),\
  37.   decrypt_skip_next(ch, state)
  38. #define decrypt_skip_next(ch, state)\
  39.   state = ((ch) + state) * crypt_c1 + crypt_c2
  40.